﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Framework;

namespace Ubatic.UI
{
    public partial class SiteMaster : BaseMasterPage
    {
        public override void PreLoad()
        {
            base.PreLoad();
            this.pnlMessages.CssClass = "pnlMessagesClass displayNone";
            this.txtMessages.Text = string.Empty;
            BuildMenu();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.Page.User.Identity.IsAuthenticated)
                {
                    Label loginName = (Label)this.HeadLoginView.FindControl("lblLoginName");
                    loginName.Text = BaseWebPage.DisplayUserName;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Instance.HandleException(ex);
            }
        }

        public override void ShowMessage(string message, WebMessageType type)
        {
            ShowMessage("Mensaje", message, type);
        }

        public override void ShowMessage(string title, string message, WebMessageType type)
        {
            this.pnlMessages.CssClass = "pnlMessagesClass displayBlock";
            this.txtErrorTitle.Text = title;
            this.txtMessages.Text = message;
            if (type != WebMessageType.Error)
            {
                pnlError.CssClass = "errorPanelMessage";
            }
            else
            {
                pnlError.CssClass = "errorPanelError";
            }
        }

        public override void MakeMenuVisible(bool visible)
        {
            this.NavigationMenu.Visible = visible;
        }

        public override void BuildMenu()
        {
        }
    }
}
